//
//  ComposeButton.swift
//  Weibo
//
//  Created by 郑克哥哥 on 2017/8/1.
//  Copyright © 2017年 郑克哥哥. All rights reserved.
//

import UIKit

//自定义撰写菜单按钮
class ComposeButton: UIButton {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        //居中等比显示
        imageView?.contentMode = .center
        //文字居中
        titleLabel?.textAlignment = .center
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    //调整子控件布局
    override func layoutSubviews() {
        super.layoutSubviews()
        //设置图片大小
        imageView?.frame.size.width = self.bounds.size.width
        imageView?.frame.size.height = self.bounds.size.width
        imageView?.frame.origin.y = 0
        
        //设置label大小
        titleLabel?.frame.size.width = self.bounds.size.width
        titleLabel?.frame.size.height = self.bounds.size.height - self.bounds.size.width
        titleLabel?.frame.origin.y = self.bounds.size.width
        titleLabel?.frame.origin.x = 0
    }

}
